﻿using ScFramework.Core;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
/// <summary>
/// 处理来自本地或远端的按键事件,并向其他模块广播
/// 目前仅处理本地事件
/// </summary>
public class KeyEventManager : LogicModuleBase<InputManager,UserManager>, IKeyEventManager
{

    List<KeyEventPair> keyList = new List<KeyEventPair>();
    public override void Update()
    {
        base.Update();
        keyList.Clear();
        foreach (var x in keySet)
        {
            if (SysModule.GetKey(x))
            {
                keyList.UniqueAdd(new KeyEventPair(x, SysModule1.UserID));
            }
        }

    }
    List<KeyCode> keySet;
    public override void Init(SubmoduleBase p, object args = null)
    {
        base.Init(p, args);
        keySet = new List<KeyCode>();
        foreach (var x in Enum.GetValues(typeof(KeyCode)))
        {
            KeyCode k = (KeyCode)x;
            if (FuncManager.CanKeyUse(k))
            {
                keySet.Add(k);
            }
        }
    }
    public List<KeyEventPair> SendKeyEvents()
    {
        var ans = new List<KeyEventPair>(keyList);

        return ans;
    }
}
public interface IKeyEventManager
{ 
    List<KeyEventPair>  SendKeyEvents();


}